<!--

    Copyright (c) 2010-2025 Eclipse Dirigible contributors

    All rights reserved. This program and the accompanying materials
    are made available under the terms of the Eclipse Public License v2.0
    which accompanies this distribution, and is available at
    http://www.eclipse.org/legal/epl-v20.html

    SPDX-FileCopyrightText: Eclipse Dirigible contributors
    SPDX-License-Identifier: EPL-2.0

-->
<!DOCTYPE HTML>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" ng-app="taskDetails" ng-controller="TaskDetailsController">

    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="icon" sizes="any" href="data:;base64,iVBORw0KGgo=">
        <title config-title></title>
        <script type="text/javascript" src="/services/web/perspective-processes/configs/bpm-task-details-window.js"></script>
        <script type="text/javascript" src="/services/js/platform-core/services/loader.js?id=view-js"></script>
        <link type="text/css" rel="stylesheet" href="/services/js/platform-core/services/loader.js?id=view-css" />
    </head>

    <body class="bk-vbox">
        <bk-busy-indicator-extended class="bk-fill-parent" ng-hide="state.error || !state.isBusy" size="l">{{state.busyText}}</bk-busy-indicator-extended>
        <table bk-table outer-borders="bottom" display-mode="compact" ng-show="!state.error && !state.isBusy" interactive="false">
            <thead bk-table-header>
                <tr bk-table-row></tr>
            </thead>
            <tbody bk-table-body>
                <tr bk-table-row ng-repeat="prop in rows track by $index">
                    <td bk-table-cell><strong>{{ prop.name }}</strong></td>
                    <td bk-table-cell>{{ prop.value }}</td>
                </tr>
            </tbody>
        </table>
        <bk-message-page glyph="sap-icon--error" ng-if="state.error">
            <bk-message-page-title>Dialog encounterd an error!</bk-message-page-title>
            <bk-message-page-subtitle>{{errorMessage}}</bk-message-page-subtitle>
        </bk-message-page>

        <script type="text/javascript">
            angular.module('taskDetails', ['platformView', 'blimpKit']).controller('TaskDetailsController', ($scope, ViewParameters) => {
                $scope.errorMessage = 'An unknown error was encountered. Please see console for more information.';
                $scope.state = {
                    isBusy: true,
                    error: false,
                    busyText: 'Loading...',
                };
                $scope.rows = [];
                const props = [
                    ['Operation type', 'operationType'],
                    ['Email', 'email'],
                    ['Created', 'createdAt'],
                    ['Finished', 'isFinished']
                ];
                
                $scope.dataParameters = ViewParameters.get();
                if (!$scope.dataParameters.hasOwnProperty('taskDetails')) {
                    $scope.state.error = true;
                    $scope.errorMessage = 'The \'taskDetails\' data parameter is missing.';
                } else {
                    for (let prop of props){
                        const value = $scope.dataParameters.taskDetails[prop[1]] || '';
                        $scope.rows.push({ name: prop[0], value });
                    }
                    $scope.state.isBusy = false;
                }
            });
        </script>
        <theme></theme>
    </body>

</html>
